{include file="../application/mobile/view/header.html" /}
</head>
<body>
<div class="bui-page">
    <header class="bui-bar">
        <div class="bui-bar-left">
            <a class="bui-btn" onclick="bui.back();"><i class="icon-back"></i></a>
        </div>
        <div class="bui-bar-main">登录</div>
        <div class="bui-bar-right">
            <!-- 右边按钮位置 -->
        </div>
    </header>
    <main>
        <!-- 正文内容 -->
        <!-- <h3 class="section-title">表单编辑</h3> -->
		<ul class="bui-list">
            <li class="bui-btn bui-box clearactive">
                <label class="bui-label" for="username">用户名:</label>
                <div class="span1">
                    <div class="bui-input user-input">
                        <input id="username" type="text" value="" placeholder="请输入用户名">
                    </div>
                </div>
            </li>
            <li class="bui-btn bui-box clearactive">
                <label class="bui-label" for="password">密码:</label>
                <div class="span1">
                    <div id="passwordInput" class="bui-input">
                        <input id="password" type="password" placeholder="请输入密码">
                    </div>
                </div>
            </li>
		</ul>
		
    </main>
    <footer>
        <!-- 底部内容 此处内容固定在页面底部 -->
        <div class="bui-btn primary" id="login">登录</div>
    </footer>
</div>

{include file="../application/mobile/view/footer.html" /}
<script>
        bui.ready(function () {
            // 控件初始化

            
        });
        // bui.btn({id:".bui-page",handle:".bui-btn,a"}).load();
        $('body').on('click','#login',function(){
                var username = $('#username').val();
                var password = $('#password').val();
                if (password == '' || username == '') {
                    bui.hint({ appendTo:"main", content:"<i class='icon-infofill'></i>用户名和密码不能为空", position:"top" , skin:'danger', showClose:true, autoClose: false});
                    return;
                }
                $.ajax({
                  url : 'login',
                  async:true,
                  type:'POST',
                  data:{
                    username:username,
                    password:password
                  },
                  dataType:'JSON',
                  success:function(data,textStatus,jqXHR){
                    data = JSON.parse(data);
                    if (data.err != '0') {
                        bui.hint({ appendTo:"main", content:"<i class='icon-infofill'></i>"+data.content, position:"top" , skin:'danger', showClose:true, autoClose: false});
                    }else{
                        bui.hint({ appendTo:"main", content:"<i class='icon-infofill'></i>"+data.content, position:"top" , skin:'success', showClose:true, autoClose: false});
                        setTimeout(function(){
                           bui.load({ url: "index"});
                        },5000);
                    }

                  },
                  error:function(){
                    
                  }
                    
                });
            });

        
    </script>
</body>
</html>